﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using VS.MainModule.Models;
using System.Collections.ObjectModel;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Prism.Regions;
using VS.Infrastructure;

namespace VS.MainModule.Views
{
    public class MainViewModel : INotifyPropertyChanged, INavigationAware
    {
        [Dependency]
        public IRegionManager RegionManager { get; set; }
        public Collection<XamlContent> MenuItems { get; private set; }

        public ICommand OpenArticle { get; set; }
        public MainViewModel()
        {
            MenuItems = new Collection<XamlContent>()
                {
                    new XamlContent() { Label="Contact", Id="contact"},
                    new XamlContent() { Label="Technologies", Id="technologies"},
                    new XamlContent() { Label="Références", Id="references"},
                    new XamlContent() { Label="Services", Id="services"}
                };

            OpenArticle = new DelegateCommand<XamlContent>(
                x => RegionManager.RequestNavigate(RegionNames.MainRegion, string.Format("/article?p0={0}", x.Id)));
        }
        
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion


        public void OnNavigatedTo(NavigationContext navigationContext)
        {
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }
    }
}
